<template>
  <BasicForm @register="registerForm" />
</template>

<script lang="ts" setup>
  import { ref, computed, unref } from 'vue';
  import { BasicForm, useForm } from '/@/components/Form/index';
  import { formSchema05 } from '../GoodsSearch.data';
  // Emits声明
  const emit = defineEmits(['register', 'handleOk', 'error']);
  const isUpdate = ref(true);
  const props = defineProps({
    isUpdate: {
      type: Boolean,
      default: false,
    },
    record: {
      type: Object,
      default: () => ({}),
    },
  });

  // 内部 isUpdate 状态
  const internalIsUpdate = ref(false);
  //表单配置
  const [registerForm, { setFieldsValue, validate }] = useForm({
    labelWidth: 150,
    schemas: formSchema05,
    showActionButtonGroup: false,
  });

  // 设置表单值
  function setFormValues(values: any) {
    // if (values.goodsDeliver) {
    setFieldsValue({
      id: values.id,
      goodsCode: values.goodsCode,
      ...JSON.parse(values.goodsDeliver),
    });
    // }
  }
  // 设置更新模式
  function setIsUpdate(value: boolean) {
    internalIsUpdate.value = value;
  }
  defineExpose({
    setFormValues,
    setIsUpdate,
  });
</script>

<style lang="less" scoped></style>
